home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2079 < prev    next >
Mailbox/MIME Entity  |  1996-08-06  |  2.3 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news, ASCII text default
100% checkBytes Printable ASCII default
100% dexmagic PrintFox/Pagefox WEAK default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/950 MIME Email (1.0) default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/news default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 6e 6e | 74 70 64 32 2e 63 78 6f |Path: nn|tpd2.cxo|
|00000010| 2e 64 65 63 2e 63 6f 6d | 21 75 73 65 6e 65 74 0a |.dec.com|!usenet.|
|00000020| 46 72 6f 6d 3a 20 42 72 | 69 61 6e 20 48 69 62 62 |From: Br|ian Hibb|
|00000030| 65 72 74 20 3c 62 5f 68 | 69 62 62 65 72 74 40 63 |ert <b_h|ibbert@c|
|00000040| 73 63 33 32 2e 65 6e 65 | 74 2e 64 65 63 2e 63 6f |sc32.ene|t.dec.co|
|00000050| 6d 3e 0a 4e 65 77 73 67 | 72 6f 75 70 73 3a 20 63 |m>.Newsg|roups: c|
|00000060| 6f 6d 70 2e 6c 61 6e 67 | 2e 63 2b 2b 0a 53 75 62 |omp.lang|.c++.Sub|
|00000070| 6a 65 63 74 3a 20 52 65 | 3a 20 44 65 73 74 72 75 |ject: Re|: Destru|
|00000080| 63 74 6f 72 73 20 69 6e | 20 66 75 6e 63 74 69 6f |ctors in| functio|
|00000090| 6e 73 0a 44 61 74 65 3a | 20 31 35 20 4a 61 6e 20 |ns.Date:| 15 Jan |
|000000a0| 31 39 39 36 20 31 39 3a | 30 39 3a 33 35 20 47 4d |1996 19:|09:35 GM|
|000000b0| 54 0a 4f 72 67 61 6e 69 | 7a 61 74 69 6f 6e 3a 20 |T.Organi|zation: |
|000000c0| 44 69 67 69 74 61 6c 20 | 45 71 75 69 70 6d 65 6e |Digital |Equipmen|
|000000d0| 74 20 43 6f 72 70 6f 72 | 61 74 69 6f 6e 0a 4d 65 |t Corpor|ation.Me|
|000000e0| 73 73 61 67 65 2d 49 44 | 3a 20 3c 34 64 65 38 70 |ssage-ID|: <4de8p|
|000000f0| 66 24 61 70 74 40 6e 6e | 74 70 64 32 2e 63 78 6f |f$apt@nn|tpd2.cxo|
|00000100| 2e 64 65 63 2e 63 6f 6d | 3e 0a 52 65 66 65 72 65 |.dec.com|>.Refere|
|00000110| 6e 63 65 73 3a 20 3c 34 | 64 37 72 36 35 24 64 76 |nces: <4|d7r65$dv|
|00000120| 39 40 6e 65 77 73 62 66 | 30 32 2e 6e 65 77 73 2e |9@newsbf|02.news.|
|00000130| 61 6f 6c 2e 63 6f 6d 3e | 0a 4e 4e 54 50 2d 50 6f |aol.com>|.NNTP-Po|
|00000140| 73 74 69 6e 67 2d 48 6f | 73 74 3a 20 70 65 6f 31 |sting-Ho|st: peo1|
|00000150| 30 31 32 5f 70 6f 72 74 | 31 2e 70 65 6f 2e 64 65 |012_port|1.peo.de|
|00000160| 63 2e 63 6f 6d 0a 4d 69 | 6d 65 2d 56 65 72 73 69 |c.com.Mi|me-Versi|
|00000170| 6f 6e 3a 20 31 2e 30 0a | 43 6f 6e 74 65 6e 74 2d |on: 1.0.|Content-|
|00000180| 54 79 70 65 3a 20 74 65 | 78 74 2f 70 6c 61 69 6e |Type: te|xt/plain|
|00000190| 3b 20 63 68 61 72 73 65 | 74 3d 75 73 2d 61 73 63 |; charse|t=us-asc|
|000001a0| 69 69 0a 43 6f 6e 74 65 | 6e 74 2d 54 72 61 6e 73 |ii.Conte|nt-Trans|
|000001b0| 66 65 72 2d 45 6e 63 6f | 64 69 6e 67 3a 20 37 62 |fer-Enco|ding: 7b|
|000001c0| 69 74 0a 58 2d 4d 61 69 | 6c 65 72 3a 20 4d 6f 7a |it.X-Mai|ler: Moz|
|000001d0| 69 6c 6c 61 20 31 2e 32 | 4e 20 28 57 69 6e 64 6f |illa 1.2|N (Windo|
|000001e0| 77 73 3b 20 49 3b 20 31 | 36 62 69 74 29 0a 54 6f |ws; I; 1|6bit).To|
|000001f0| 3a 20 77 65 61 74 62 79 | 40 61 6f 6c 2e 63 6f 6d |: weatby|@aol.com|
|00000200| 0a 0a 77 65 61 74 62 79 | 40 61 6f 6c 2e 63 6f 6d |..weatby|@aol.com|
|00000210| 20 28 57 65 61 74 62 79 | 29 20 77 72 6f 74 65 3a | (Weatby|) wrote:|
|00000220| 0a 3e 49 66 20 79 6f 75 | 20 70 61 73 73 20 61 6e |.>If you| pass an|
|00000230| 20 6f 62 6a 65 63 74 20 | 74 6f 20 61 20 66 75 6e | object |to a fun|
|00000240| 63 74 69 6f 6e 2c 20 74 | 68 65 20 6c 61 6e 67 75 |ction, t|he langu|
|00000250| 61 67 65 20 6d 61 6b 65 | 73 20 61 20 62 69 74 77 |age make|s a bitw|
|00000260| 69 73 65 20 63 6f 70 79 | 20 6f 66 0a 3e 69 74 2c |ise copy| of.>it,|
|00000270| 20 6c 6f 63 61 6c 20 74 | 6f 20 74 68 65 20 66 75 | local t|o the fu|
|00000280| 6e 63 74 69 6f 6e 2e 20 | 20 28 41 73 73 75 6d 69 |nction. | (Assumi|
|00000290| 6e 67 20 6e 6f 20 63 6f | 70 79 20 63 6f 6e 73 74 |ng no co|py const|
|000002a0| 72 75 63 74 6f 72 20 69 | 73 20 64 65 66 69 6e 65 |ructor i|s define|
|000002b0| 64 2e 29 20 0a 3e 54 68 | 65 6e 2c 20 6f 6e 20 74 |d.) .>Th|en, on t|
|000002c0| 68 65 20 77 61 79 20 6f | 75 74 2c 20 74 68 65 20 |he way o|ut, the |
|000002d0| 66 75 6e 63 74 69 6f 6e | 20 63 61 6c 6c 73 20 74 |function| calls t|
|000002e0| 68 65 20 75 73 65 72 2d | 64 65 66 69 6e 65 64 20 |he user-|defined |
|000002f0| 63 6f 6e 73 74 72 75 63 | 74 6f 72 2e 0a 3e 0a 0a |construc|tor..>..|
|00000300| 41 73 20 6f 74 68 65 72 | 73 20 68 61 76 65 20 70 |As other|s have p|
|00000310| 6f 69 6e 74 65 64 20 6f | 75 74 2c 20 74 68 65 20 |ointed o|ut, the |
|00000320| 63 6f 6d 70 69 6c 65 72 | 20 73 68 6f 75 6c 64 20 |compiler| should |
|00000330| 64 6f 20 61 20 6d 65 6d | 62 65 72 77 69 73 65 20 |do a mem|berwise |
|00000340| 63 6f 70 79 20 6f 66 20 | 0a 74 68 65 20 6f 62 6a |copy of |.the obj|
|00000350| 65 63 74 2e 20 20 59 6f | 75 20 63 61 6e 20 61 76 |ect. Yo|u can av|
|00000360| 6f 69 64 20 6d 75 63 68 | 20 6f 66 20 74 68 69 73 |oid much| of this|
|00000370| 20 62 79 20 70 61 73 73 | 69 6e 67 20 61 20 72 65 | by pass|ing a re|
|00000380| 66 65 72 65 6e 63 65 20 | 74 6f 20 74 68 65 20 0a |ference |to the .|
|00000390| 6f 62 6a 65 63 74 20 28 | 77 68 69 63 68 20 73 68 |object (|which sh|
|000003a0| 6f 75 6c 64 20 6e 6f 74 | 20 63 61 6c 6c 20 61 20 |ould not| call a |
|000003b0| 63 6f 70 79 20 63 6f 6e | 73 74 72 75 63 74 6f 72 |copy con|structor|
|000003c0| 29 2e 0a 0a 3e 54 68 69 | 73 20 77 69 6c 6c 20 63 |)...>Thi|s will c|
|000003d0| 61 75 73 65 20 70 72 6f | 62 6c 65 6d 73 20 69 66 |ause pro|blems if|
|000003e0| 20 74 68 65 20 6f 62 6a | 65 63 74 20 68 61 73 20 | the obj|ect has |
|000003f0| 61 6e 79 20 70 6f 69 6e | 74 65 72 73 20 69 6e 20 |any poin|ters in |
|00000400| 69 74 20 28 69 66 20 74 | 68 65 79 20 61 72 65 0a |it (if t|hey are.|
|00000410| 3e 72 65 6c 65 61 73 65 | 64 20 62 79 20 74 68 65 |>release|d by the|
|00000420| 20 64 65 73 74 72 75 63 | 74 6f 72 2c 20 61 73 20 | destruc|tor, as |
|00000430| 74 68 65 79 20 27 73 68 | 6f 75 6c 64 27 20 62 65 |they 'sh|ould' be|
|00000440| 29 2e 0a 3e 0a 54 68 69 | 73 20 69 73 20 74 72 75 |)..>.Thi|s is tru|
|00000450| 65 2c 20 69 74 20 77 69 | 6c 6c 20 63 61 75 73 65 |e, it wi|ll cause|
|00000460| 20 70 72 6f 62 6c 65 6d | 73 2e 2e 2e 2e 0a 0a 3e | problem|s......>|
|00000470| 54 68 65 20 71 75 65 73 | 74 69 6f 6e 20 69 73 2c |The ques|tion is,|
|00000480| 20 77 68 79 20 63 61 6c | 6c 20 61 20 64 65 73 74 | why cal|l a dest|
|00000490| 72 75 63 74 6f 72 20 6f | 6e 20 61 6e 20 6f 62 6a |ructor o|n an obj|
|000004a0| 65 63 74 20 66 6f 72 20 | 77 68 69 63 68 20 6e 6f |ect for |which no|
|000004b0| 0a 3e 63 6f 6e 73 74 72 | 75 63 74 6f 72 20 77 61 |.>constr|uctor wa|
|000004c0| 73 20 63 61 6c 6c 65 64 | 3f 20 20 54 68 65 20 63 |s called|? The c|
|000004d0| 6f 6d 70 69 6c 65 72 20 | 68 61 73 20 70 72 6f 62 |ompiler |has prob|
|000004e0| 61 62 6c 79 20 70 75 74 | 20 74 68 65 20 6c 6f 63 |ably put| the loc|
|000004f0| 61 6c 20 63 6f 70 79 20 | 6f 6e 0a 3e 69 74 73 20 |al copy |on.>its |
|00000500| 73 74 61 63 6b 2c 20 61 | 6e 64 20 63 6f 75 6c 64 |stack, a|nd could|
|00000510| 20 70 6f 70 20 69 74 20 | 6f 66 66 20 6f 6e 20 74 | pop it |off on t|
|00000520| 68 65 20 77 61 79 20 6f | 75 74 2e 0a 3e 0a 0a 59 |he way o|ut..>..Y|
|00000530| 6f 75 20 61 72 65 20 6d | 61 6b 69 6e 67 20 74 68 |ou are m|aking th|
|00000540| 65 20 77 72 6f 6e 67 20 | 61 73 73 75 6d 70 74 69 |e wrong |assumpti|
|00000550| 6f 6e 20 68 65 72 65 2e | 20 20 59 6f 75 20 73 61 |on here.| You sa|
|00000560| 79 20 74 68 61 74 20 6e | 6f 20 63 6f 6e 73 74 72 |y that n|o constr|
|00000570| 75 63 74 6f 72 20 69 73 | 20 0a 63 61 6c 6c 65 64 |uctor is| .called|
|00000580| 2e 20 20 54 68 69 73 20 | 69 73 20 6e 6f 74 20 65 |. This |is not e|
|00000590| 78 63 61 70 74 6c 79 20 | 74 72 75 65 2e 20 20 54 |xcaptly |true. T|
|000005a0| 68 65 72 65 20 69 73 20 | 6e 6f 20 75 73 65 72 20 |here is |no user |
|000005b0| 64 65 66 69 6e 65 64 20 | 63 6f 70 79 20 0a 63 6f |defined |copy .co|
|000005c0| 6e 73 74 72 75 63 74 6f | 72 2c 20 62 75 74 20 74 |nstructo|r, but t|
|000005d0| 68 65 20 63 6f 6d 70 6c | 69 65 72 20 73 75 70 70 |he compl|ier supp|
|000005e0| 6c 69 65 73 20 61 20 64 | 65 66 61 75 6c 74 20 6f |lies a d|efault o|
|000005f0| 6e 65 20 28 74 68 65 20 | 6d 65 6d 62 65 72 77 69 |ne (the |memberwi|
|00000600| 73 65 20 0a 63 6f 70 79 | 29 2e 20 20 54 68 65 72 |se .copy|). Ther|
|00000610| 65 20 69 73 20 61 20 63 | 6f 6e 73 74 72 75 63 74 |e is a c|onstruct|
|00000620| 6f 72 20 62 65 69 6e 67 | 20 63 61 6c 6c 65 64 2e |or being| called.|
|00000630| 20 20 49 66 20 74 68 69 | 73 20 64 65 66 61 75 6c | If thi|s defaul|
|00000640| 74 20 63 6f 6e 73 74 72 | 75 63 74 6f 72 20 0a 69 |t constr|uctor .i|
|00000650| 73 20 6e 6f 74 20 70 72 | 6f 76 69 64 69 6e 67 20 |s not pr|oviding |
|00000660| 63 6f 72 72 65 63 74 20 | 62 65 68 61 76 69 6f 72 |correct |behavior|
|00000670| 20 28 61 6c 6d 6f 73 74 | 20 61 6c 77 61 79 73 20 | (almost| always |
|00000680| 74 72 75 65 20 77 68 65 | 6e 20 79 6f 75 20 61 72 |true whe|n you ar|
|00000690| 65 20 75 73 69 6e 67 20 | 0a 70 6f 69 6e 74 65 72 |e using |.pointer|
|000006a0| 73 20 74 6f 20 64 79 6e | 61 6d 69 63 61 6c 6c 79 |s to dyn|amically|
|000006b0| 20 61 6c 6c 6f 63 61 74 | 65 64 20 6d 65 6d 6f 72 | allocat|ed memor|
|000006c0| 79 29 20 74 68 65 6e 20 | 79 6f 75 20 6e 65 65 64 |y) then |you need|
|000006d0| 0a 74 6f 20 73 75 70 70 | 6c 79 20 61 20 63 6f 70 |.to supp|ly a cop|
|000006e0| 79 20 63 6f 6e 73 74 72 | 75 63 74 6f 72 20 74 68 |y constr|uctor th|
|000006f0| 61 74 20 62 65 68 61 76 | 65 73 20 63 6f 72 72 65 |at behav|es corre|
|00000700| 63 74 6c 79 2e 0a 0a 0a | 3e 43 61 6c 6c 69 6e 67 |ctly....|>Calling|
|00000710| 20 61 20 64 65 73 74 72 | 75 63 74 6f 72 2c 20 61 | a destr|uctor, a|
|00000720| 75 74 6f 6d 61 74 69 63 | 61 6c 6c 79 2c 20 66 6f |utomatic|ally, fo|
|00000730| 72 20 77 68 69 63 68 20 | 6e 6f 20 63 6f 6e 73 74 |r which |no const|
|00000740| 72 75 63 74 6f 72 20 77 | 61 73 20 63 61 6c 6c 65 |ructor w|as calle|
|00000750| 64 0a 3e 73 65 65 6d 73 | 20 74 6f 20 62 65 20 61 |d.>seems| to be a|
|00000760| 20 6e 6f 6e 2d 75 73 65 | 66 75 6c 20 66 65 61 74 | non-use|ful feat|
|00000770| 75 72 65 2e 20 20 44 6f | 65 73 20 61 6e 79 6f 6e |ure. Do|es anyon|
|00000780| 65 20 6b 6e 6f 77 20 77 | 68 79 20 74 68 69 73 20 |e know w|hy this |
|00000790| 77 61 73 20 69 6e 63 6c | 75 64 65 64 0a 3e 69 6e |was incl|uded.>in|
|000007a0| 20 74 68 65 20 6c 61 6e | 67 75 61 67 65 20 64 65 | the lan|guage de|
|000007b0| 66 69 6e 69 74 69 6f 6e | 3f 0a 3e 0a 0a 41 73 20 |finition|?.>..As |
|000007c0| 73 74 61 74 65 64 20 61 | 62 6f 76 65 2c 20 61 20 |stated a|bove, a |
|000007d0| 63 6f 6e 73 74 72 75 63 | 74 6f 72 20 69 73 20 62 |construc|tor is b|
|000007e0| 65 69 6e 67 20 63 61 6c | 6c 65 64 20 66 6f 72 20 |eing cal|led for |
|000007f0| 74 68 65 20 6f 62 6a 65 | 63 74 2e 20 54 68 65 20 |the obje|ct. The |
|00000800| 66 61 63 74 20 0a 74 68 | 61 74 20 74 68 65 20 63 |fact .th|at the c|
|00000810| 6f 6e 73 74 72 75 63 74 | 6f 72 20 64 6f 65 73 6e |onstruct|or doesn|
|00000820| 27 74 20 62 65 68 61 76 | 65 20 63 6f 72 72 65 63 |'t behav|e correc|
|00000830| 74 6c 79 20 69 73 20 6e | 6f 74 20 74 68 65 20 66 |tly is n|ot the f|
|00000840| 61 75 6c 74 20 6f 66 20 | 74 68 65 20 0a 6c 61 6e |ault of |the .lan|
|00000850| 67 75 61 67 65 2e 20 20 | 0a 0a 3e 54 68 61 6e 6b |guage. |..>Thank|
|00000860| 73 2e 0a 3e 0a 3e 42 6f | 62 0a 0a 0a 2d 2d 20 0a |s..>.>Bo|b...-- .|
|00000870| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000880| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000890| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 0a |********|*******.|
|000008a0| 42 72 69 61 6e 20 48 69 | 62 62 65 72 74 20 20 62 |Brian Hi|bbert b|
|000008b0| 5f 68 69 62 62 65 72 74 | 40 63 73 63 33 32 2e 65 |_hibbert|@csc32.e|
|000008c0| 6e 65 74 2e 64 65 63 2e | 63 6f 6d 0a 44 69 67 69 |net.dec.|com.Digi|
|000008d0| 74 61 6c 20 45 71 75 69 | 70 6d 65 6e 74 20 43 6f |tal Equi|pment Co|
|000008e0| 72 70 6f 72 61 74 69 6f | 6e 0a 41 6c 6c 20 6f 70 |rporatio|n.All op|
|000008f0| 69 6e 69 6f 6e 73 20 65 | 78 70 72 65 73 73 65 64 |inions e|xpressed|
|00000900| 20 61 72 65 20 6d 79 20 | 6f 77 6e 20 61 6e 64 20 | are my |own and |
|00000910| 73 68 6f 75 6c 64 0a 6e | 6f 74 20 62 65 20 61 73 |should.n|ot be as|
|00000920| 73 75 6d 65 64 20 74 6f | 20 62 65 20 74 68 65 20 |sumed to| be the |
|00000930| 6f 70 69 6e 69 6f 6e 20 | 6f 66 20 6d 79 20 65 6d |opinion |of my em|
|00000940| 70 6c 6f 79 65 72 0a 0a | 0a |ployer..|. |
+--------+-------------------------+-------------------------+--------+--------+